clear;
global x0 target_pos;
global N1;
global m_wet_log;
global alpha;
global dt;
global g;
global y_gs_cot p_cs_cos;
global V_max;
global z0_term_log_1 z0_term_inv_1;
global Tt_max Tt_min;
%% 火星登陆器参数
alpha = 5e-4; %喷气速度，也是一种比冲定义形式
V_max = 90;
y_gs = pi/6;
y_gs_cot = cot(y_gs);
p_cs = pi/4;
p_cs_cos = cos(p_cs);
m_wet = 2e3;
m_wet_log = log(m_wet);
m_fuel = 3e2;
T_max = 2.4e4;
throt_max = 0.8;
throt_min = 0.2;
Tt_max = T_max*throt_max;
Tt_min = T_max*throt_min;
x0 = [2400,450,-330,-10,-40,10]';
target_pos = [0, 0, 0]';
g = [-3.71,0,0]';
dt = 0.5;
N1 = 160;
t1 = linspace(0,(N1-1)*dt,N1);
z0_term_1 = m_wet-alpha*Tt_max*t1;
z0_term_log_1 = log(z0_term_1);
z0_term_inv_1 = 1./z0_term_1;
N2 = 80;
t2 = linspace(0,(N2-1)*dt,N2);
z0_term_2 = m_wet-alpha*Tt_max*t2;
z0_term_log_2 = log(z0_term_2);
z0_term_inv_2 = 1./z0_term_2;

%% 猎鹰9参数
% g = [-9.80665, 0, 0]';
% V_max = 1300;
% Isp   = 282;
% alpha = 1/(Isp*g(1));
% m_dry = (22.2)*1e3;
% m_fuel= (13.4)*1e3;
% m_wet = (m_dry+m_fuel);
% m_wet_log = log(m_wet);
% T_max = 845000*3;
% throt_max = 0.4;
% throt_min = 0.1;
% Tt_max = T_max*throt_max;
% Tt_min = T_max*throt_min;
% dt = 0.5;
% N1 = 160;
% t1 = linspace(0,(N1-1)*dt,N1);
% z0_term_1 = m_wet-alpha*Tt_max*t1;
% z0_term_log_1 = log(z0_term_1);
% z0_term_inv_1 = 1./z0_term_1;
% N2 = 80;
% t2 = linspace(0,(N2-1)*dt,N2);
% z0_term_2 = m_wet-alpha*Tt_max*t2;
% z0_term_log_2 = log(z0_term_2);
% z0_term_inv_2 = 1./z0_term_2;
% x0 = [20000,10,5,-500,-100,-200]';
% target_pos = [0, 0, 0]';
% y_gs = 1/180*pi;
% y_gs_cot = cot(y_gs);
% p_cs = pi/3*2;
% p_cs_cos = cos(p_cs);